<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>联系我们 - 汉中旅游</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/contact.css">
</head>
<body>
    <!-- 页面加载动画 -->
    <div class="page-loader">
        <div class="loader"></div>
    </div>

    <!-- 用户小部件 -->
    <div class="user-widget">
        <a href="login.html" id="login-link" class="btn btn-login">登录/注册</a>
        <div id="user-profile" style="display: none;">
            <img src="img/attractions/touxiang.jpg" alt="User Avatar" class="avatar">
            <span id="username-display"></span>
            <a href="#" id="logout-link" title="退出登录"><i class="fas fa-sign-out-alt"></i></a>
        </div>
    </div>

    <!-- 浮动导航菜单 -->
    <div class="float-nav">
        <button class="float-nav-toggle" id="floatNavToggle" title="快速导航">
            <i class="fas fa-bars"></i>
        </button>
        <div class="float-nav-menu" id="floatNavMenu">
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="jingdian.html">景点介绍</a></li>
                <li><a href="luxian.html">旅游线路</a></li>
                <li><a href="gonglue.html">旅游攻略</a></li>
                <li><a href="meishi.html">美食推荐</a></li>
                <li><a href="wenhua.html">汉文化活动</a></li>
                <li><a href="contact.html" class="active">联系我们</a></li>
                <li><a href="faq.html">常见问题</a></li>
            </ul>
        </div>
    </div>

    <!-- 导航栏 -->
    <nav>
        <div class="container">
            <div class="nav-container">
                <div class="nav-logo">
                    <img src="img/attractions/logo.jpg" alt="汉中旅游" style="height: 45px; border-radius: 5px; margin-right: 10px;">
                    <h2 style="color: #ffffff; font-weight: bold;">汉中旅游</h2>
                </div>
                <ul class="main-nav">
                    <li><a href="index.html">首页</a></li>
                    <li class="dropdown">
                        <a href="jingdian.html">景点介绍</a>
                        <div class="dropdown-content">
                            <a href="jingdian.html#natural">自然风光</a>
                            <a href="jingdian.html#historical">历史古迹</a>
                            <a href="jingdian.html#cultural">文化景观</a>
                        </div>
                    </li>
                    <li class="dropdown">
                        <a href="luxian.html">旅游线路</a>
                        <div class="dropdown-content">
                            <a href="luxian.html#oneday">一日游</a>
                            <a href="luxian.html#threedays">三日游</a>
                            <a href="luxian.html#fivedays">五日游</a>
                        </div>
                    </li>
                    <li class="dropdown">
                        <a href="gonglue.html">旅游攻略</a>
                        <div class="dropdown-content">
                            <a href="gonglue.html#transportation">交通指南</a>
                            <a href="gonglue.html#accommodation">住宿推荐</a>
                            <a href="gonglue.html#tips">注意事项</a>
                            <a href="gonglue.html#besttime">最佳旅游时间</a>
                        </div>
                    </li>
                    <li><a href="meishi.html">美食推荐</a></li>
                    <li><a href="wenhua.html">汉文化活动</a></li>
                    <li><a href="contact.html" class="active">联系我们</a></li>
                    <li><a href="faq.html">常见问题</a></li>
                </ul>
                <!-- 用户操作区域已被移到独立的 user-widget 中 -->
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main>
        <!-- 页面标题 -->
        <section class="page-header">
            <div class="container">
                <h1>联系我们</h1>
                <p>随时为您提供旅游咨询和帮助</p>
            </div>
        </section>

        <!-- 联系信息和表单 -->
        <section class="container section-padding">
            <div class="contact-container">
                <div class="contact-info">
                    <h2>联系方式</h2>
                    <div class="info-item">
                        <div class="info-icon">
                            <i class="fas fa-map-marker-alt"></i>
                        </div>
                        <div class="info-content">
                            <h3>地址</h3>
                            <p>陕西省汉中市汉台区民主街28号</p>
                            <p>汉中旅游信息中心</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i class="fas fa-phone"></i>
                        </div>
                        <div class="info-content">
                            <h3>电话</h3>
                            <p>旅游咨询热线: 0916-123456</p>
                            <p>投诉建议: 0916-654321</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i class="fas fa-envelope"></i>
                        </div>
                        <div class="info-content">
                            <h3>电子邮箱</h3>
                            <p>info@hanzhong-tourism.com</p>
                            <p>service@hanzhong-tourism.com</p>
                        </div>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i class="fas fa-clock"></i>
                        </div>
                        <div class="info-content">
                            <h3>工作时间</h3>
                            <p>周一至周五: 09:00 - 17:30</p>
                            <p>周六至周日: 09:30 - 17:00</p>
                        </div>
                    </div>
                    <div class="social-contact">
                        <h3>社交媒体</h3>
                        <div class="social-icons">
                            <a href="#" class="social-icon"><i class="fab fa-weibo"></i></a>
                            <a href="#" class="social-icon"><i class="fab fa-weixin"></i></a>
                            <a href="#" class="social-icon"><i class="fab fa-qq"></i></a>
                            <a href="#" class="social-icon"><i class="fab fa-tiktok"></i></a>
                        </div>
                    </div>
                </div>
                <div class="contact-form">
                    <h2>在线咨询</h2>
                    <p>如有任何问题或需求，请填写下面的表单，我们会尽快回复您。</p>
                    <form id="contactForm">
                        <div class="form-group">
                            <label for="name">姓名 <span class="required">*</span></label>
                            <input type="text" id="name" name="name" required>
                        </div>
                        <div class="form-group">
                            <label for="email">电子邮箱 <span class="required">*</span></label>
                            <input type="email" id="email" name="email" required>
                        </div>
                        <div class="form-group">
                            <label for="phone">电话</label>
                            <input type="tel" id="phone" name="phone">
                        </div>
                        <div class="form-group">
                            <label for="subject">主题 <span class="required">*</span></label>
                            <select id="subject" name="subject" required>
                                <option value="">请选择咨询主题</option>
                                <option value="travel">旅游线路咨询</option>
                                <option value="booking">预订服务</option>
                                <option value="complaint">投诉建议</option>
                                <option value="cooperation">商务合作</option>
                                <option value="other">其他</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="message">留言内容 <span class="required">*</span></label>
                            <textarea id="message" name="message" rows="5" required></textarea>
                        </div>
                        <div class="form-group">
                            <button type="submit" class="btn" style="background-color: #DC4E42;">提交</button>
                        </div>
                    </form>
                    
                    <!-- 提交成功消息 -->
                    <div id="successMessage" style="display: none; background-color: #f0f8f0; border-left: 4px solid #DC4E42; padding: 15px; margin-top: 20px; border-radius: 4px;">
                        <h3 style="color: #DC4E42; margin-top: 0;"><i class="fas fa-check-circle"></i> 提交成功!</h3>
                        <p>感谢您的留言，我们会尽快回复您。</p>
                        <button onclick="resetForm()" style="background-color: #DC4E42; color: white; border: none; padding: 8px 15px; border-radius: 4px; cursor: pointer; margin-top: 10px;">继续咨询</button>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- 页脚 -->
    <footer>
        <div class="container">
            <div class="footer-content">
                <div class="footer-section">
                    <h3>关于我们</h3>
                    <p>汉中旅游网致力于为游客提供最全面的汉中旅游信息，让您的汉中之行更加便捷、愉快。</p>
                    <div class="social-links">
                        <a href="#"><i class="fab fa-weibo"></i></a>
                        <a href="#"><i class="fab fa-weixin"></i></a>
                        <a href="#"><i class="fab fa-qq"></i></a>
                    </div>
                </div>
                <div class="footer-section">
                    <h3>快速链接</h3>
                    <ul>
                        <li><a href="index.html">首页</a></li>
                        <li><a href="jingdian.html">景点介绍</a></li>
                        <li><a href="luxian.html">旅游线路</a></li>
                        <li><a href="gonglue.html">旅游攻略</a></li>
                        <li><a href="contact.html">联系我们</a></li>
                    </ul>
                </div>
                <div class="footer-section">
                    <h3>热门景点</h3>
                    <ul>
                        <li><a href="jingdian.html#wuhoumu">武侯墓</a></li>
                        <li><a href="jingdian.html#nanhu">南湖</a></li>
                        <li><a href="jingdian.html#dingjunshan">定军山</a></li>
                        <li><a href="jingdian.html#guchengqiang">古城墙</a></li>
                    </ul>
                </div>
                <div class="footer-section">
                    <h3>联系方式</h3>
                    <p><i class="fas fa-map-marker-alt"></i> 地址：陕西省汉中市</p>
                    <p><i class="fas fa-phone"></i> 电话：0916-123456</p>
                    <p><i class="fas fa-envelope"></i> 邮箱：info@hanzhong-tourism.com</p>
                </div>
            </div>
        </div>
        <div class="footer-bottom">
            <div class="container">
                <p>&copy; 2023 汉中旅游网 版权所有</p>
            </div>
        </div>
    </footer>

    <script src="js/main.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const contactForm = document.getElementById('contactForm');
            const successMessage = document.getElementById('successMessage');
    
            contactForm.addEventListener('submit', function (event) {
                event.preventDefault();
    
                const token = localStorage.getItem('jwt_token');
                if (!token) {
                    alert('请先登录再提交咨询！');
                    window.location.href = 'login.html';
                    return;
                }
    
                const formData = new FormData(contactForm);
                const data = {
                    name: formData.get('name'),
                    email: formData.get('email'),
                    phone: formData.get('phone'),
                    subject: formData.get('subject'),
                    message: formData.get('message')
                };
    
                fetch('/api/contact', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': 'Bearer ' + token
                    },
                    body: JSON.stringify(data)
                })
                .then(response => {
                    if (response.ok) {
                        return response.json();
                    } else {
                        // Handle HTTP errors, e.g., 401 Unauthorized, 403 Forbidden
                        throw new Error('提交失败，请确保您已登录或稍后重试。');
                    }
                })
                .then(data => {
                    console.log('Success:', data);
                    contactForm.style.display = 'none';
                    successMessage.style.display = 'block';
                    successMessage.scrollIntoView({ behavior: 'smooth' });
                })
                .catch((error) => {
                    console.error('Error:', error);
                    alert(error.message);
                });
            });
        });
    
        // 重置表单
        function resetForm() {
            const contactForm = document.getElementById('contactForm');
            const successMessage = document.getElementById('successMessage');
            
            // 清空表单
            contactForm.reset();
            
            // 显示表单
            contactForm.style.display = 'block';
            
            // 隐藏成功消息
            successMessage.style.display = 'none';
        }
    </script>
    <script src="js/script.js"></script>
    <style>
        /* 联系页面特定样式 */
        
        /* 表单提交按钮悬停效果 */
        .btn:hover {
            background-color: #c13c30 !important;
            transition: background-color 0.3s ease;
        }
        
        /* 表单提交成功动画 */
        #successMessage {
            animation: fadeIn 0.5s ease;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-20px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</body>
</html> 